<ol class="breadcrumb">
    <li><a href="#">奇妙云箱</a></li>
    <li><a href="/prize/list">奖品管理</a></li>
    <li>编辑奖品</li>
</ol>
<div class="panel panel-default">
    <div class="panel-heading">
        <span class="glyphicon glyphicon-pencil"></span>
        <span class="panel-title">请填写奖品信息</span>
    </div>
    <div class="panel-body">
        <div class="container" id="crop-avatar">

            <form action="/prize/edit" onsubmit="return check()" method="post" name="form3"
                  class="form-horizontal">

                <div class="form-group">
                    <label class="control-label col-xs-2">奖品图片：</label>

                    <div class="col-xs-9">
                        <img src="<%= prizedata.imgurl %>" class="avatar-view" >
                    </div>
                </div>

                <div class="form-group">
                    <label class="control-label col-xs-2">奖品名称：</label>

                    <div class="col-xs-9">
                        <input type="text" class="form-control" id="name" name="name" placeholder="请输入奖品名称" value="<%= prizedata.name %>"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-2">奖品价格：</label>

                    <div class="col-xs-9">
                        <input type="text" class="form-control" id="price" name="price" placeholder="请输入奖品价格" value="<%= prizedata.price %>"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-2">奖品链接：</label>

                    <div class="col-xs-9">
                        <input type="text" class="form-control" id="taobao_url" name="taobao_url"
                               placeholder="请输入奖品链接" value="<%= prizedata.taobao_url %>"/>
                        <input type="text" id="imgurl" name="imgurl" value="<%= prizedata.imgurl %>" style="display: none"/>
                        <input type="text" id="id" name="id" value="<%= id %>" style="display: none"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-2">微信商品ID：</label>

                    <div class="col-xs-9">
                        <input type="text" class="form-control" id="wechat_productId" name="wechat_productId"
                               placeholder="请输入微信商品ID" value="<%= prizedata.wechat_url %>"/>
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-xs-9 col-xs-offset-2">
                        <input type="submit" class="btn btn-success col-xs-2"
                               id="sub_btn">
                    </div>
                </div>
            </form>

            <!-- Cropping modal -->
            <div class="modal fade" id="avatar-modal" aria-hidden="true" aria-labelledby="avatar-modal-label"
                 role="dialog" tabindex="-1">
                <div class="modal-dialog modal-lg">
                    <div class="modal-content">
                        <form class="avatar-form" action="/box_management/uploadimg" enctype="multipart/form-data"
                              method="post">
                            <div class="modal-header">
                                <button class="close" data-dismiss="modal" type="button">&times;</button>
                                <h4 class="modal-title" id="avatar-modal-label">裁剪图片</h4>
                            </div>
                            <div class="modal-body">
                                <div class="avatar-body">

                                    <!-- Upload image and data -->
                                    <div class="avatar-upload">
                                        <input class="avatar-src" name="avatar_src" type="hidden">
                                        <input class="avatar-data" name="avatar_data" type="hidden">

                                        <div class="col-xs-9">
                                            <input class="avatar-input form-control" id="avatarInput"
                                                   name="avatar_file"
                                                   type="file">
                                        </div>
                                        <button class="btn btn-success col-xs-2" type="submit">上传</button>

                                    </div>

                                    <!-- Crop and preview -->
                                    <div class="row">
                                        <div class="col-xs-12">
                                            <div class="avatar-wrapper"></div>
                                        </div>
                                    </div>

                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>

            <!-- Loading state -->
            <div class="loading" aria-label="Loading" role="img" tabindex="-1"></div>
        </div>
    </div>
</div>

<!-- cropper -->
<link href="/lib/cropper/cropper.min.css" rel="stylesheet">
<link href="/lib/cropper/main.css" rel="stylesheet">
<script src="/lib/cropper/cropper.min.js"></script>
<script src="/lib/cropper/main.js"></script>
<script>
    function check() {
        var imgurl = $('#imgurl').val();
        var name = $('#name').val();
        var price = $('#price').val();
        var taobao_url = $('#taobao_url').val();
        var wechat_productId = $('#wechat_productId').val();
        if (imgurl == '' || name == '' || price == '' || taobao_url == '' || wechat_productId == '') {
            $('#lert').html("<div class='alert alert-error'><h4>请完善资料.</h4></div>");
            return false;
        } else {
            return true;
        }

    }

</script>